#ifndef BASE_DESK_H
#define BASE_DESK_H
#include <set>
class BasePlayer;
class BaseRoom;
class JMsgProto;
class BaseDesk
{
public:
	BaseDesk(void);
	~BaseDesk(void);
	
public:
	virtual void onPlayerJoin(BasePlayer* player);
	virtual void onPlayerLeave(BasePlayer* player);
	virtual void onPlayerDisconnect(BasePlayer* player);
	virtual void onPlayerData(BasePlayer* player, void* data, int len);
public:
	void brocastData(void* data, int len, BasePlayer* except = NULL);
	void tickPlayer(BasePlayer* player); 
	int getEmptyChairId();
private:
	void brocast(int mainCmd, int subCmd, void* data, int len, BasePlayer* except = NULL);
	friend class BaseGameImpl;
	void procPlayerJoin(BasePlayer* player, int deskId, int chairId);
	void procPlayerLeave(BasePlayer* player);

	friend class BaseRoom;
	bool hasPlayerSitted();
public:
	int m_id;
	bool m_isFriend;
	std::string m_deskCode;
	BaseRoom* m_room;
	BasePlayer* m_chairPlayers[4];
	std::set<BasePlayer*> m_setPlayers;
	JMsgProto* m_proto;
};
#endif
